home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4909 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Fastest way to computer log(base2) of x?
  5. Date: 7 Feb 1996 20:38:36 GMT
  6. Organization: Borland International
  7. Message-ID: <4fb2kc$i8n@druid.borland.com>
  8. References: <4e61iu$p6e@villa.fc.net> <4e72il$dvl@ns.RezoNet.NET> <4f647p$lc5@druid.borland.com> <9602061633.AA15316@dxmint.cern.ch>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <9602061633.AA15316@dxmint.cern.ch>, danpop@mail.cern.ch says...
  15. >
  16. >pete@borland.com (Pete Becker) writes:
  17. >
  18. >>Still faster: use a table with INT_MAX entries and remove all of the 
  19. >>conditionals. Why do the responses here assume that sacrificing speed for 
  20. >>space savings is appropriate? The question asks for the fastest, not 
  21. something 
  22. >>that's reasonably fast but doesn't use much space.
  23. >
  24. >Initializing a table with 2147483648 entries might take quite a lot of
  25. >time.  That is, assuming that the system is configured with enough virtual
  26. >memory :-)
  27.  
  28. Yes, but that's a one-time cost, and amortized over many lookups it becomes 
  29. vanishingly small. So the limiting case is that the cost of making this 
  30. determination is a single memory access. That is, assuming that the system is 
  31. configured with enough real memory. <g>
  32.  
  33.